package com.bear.cmcc.NetTestHTTP.ui.view;




import com.bear.cmcc.NetTestHTTP.R;

import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

/**
 * 加载控件
 * @author meizhen.xu
 *
 */
public class LoadingLayout extends LinearLayout {

	
	private Context context;
	private LinearLayout mainLayout;
	
	private ProgressBar bar;
	private TextView text;
	
	
	public LoadingLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
		init();
	}

	public LoadingLayout(Context context) {
		super(context);
		this.context = context;
		init();
	}
	
	private void init(){
		View view = LayoutInflater.from(context).inflate(R.layout.list_loading, null);
		mainLayout = (LinearLayout)view.findViewById(R.id.loading_mainLayout);
		bar = (ProgressBar)view.findViewById(R.id.loading_bar);
		text = (TextView)view.findViewById(R.id.loading_text);
		
		mainLayout.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
			}
		});
		
		
		bar.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
			}
		});
		
		text.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
			}
		});
		
		this.addView(view);
	}

	public TextView getText() {
		return text;
	}
	
	public void show(){
		this.setVisibility(View.VISIBLE);
	}
	
	public void hide(){
		this.setVisibility(View.GONE);
	}
	
	@Override
    public void onWindowFocusChanged(boolean hasFocus) {
		super.onWindowFocusChanged(hasFocus);
	}
	
	
}
